Skip to content

feat: carry --metadata-file through the bake build strategy - #733

Merged
bschwedler merged 2 commits into
mainfrom
feat/bake-metadata-files
Aug 17, 2026
Merged

feat: carry --metadata-file through the bake build strategy#733
bschwedler merged 2 commits into
mainfrom
feat/bake-metadata-files

Conversation

@ianpittwood

@ianpittwood ianpittwood commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

python-on-whales 0.81.0 added metadata_file support to docker.buildx.bake(), matching the existing docker.build() support. This wires bakery build --metadata-file through the --strategy bake path, which previously ignored it.

  • BakePlan.build() now accepts metadata_file and forwards it to docker buildx bake --metadata-file.
  • BakeryConfig.build_targets()'s BAKE branch passes metadata_file through to BakePlan.build() and, on success, loads the resulting file back into each target's build_metadata. buildx bake --metadata-file writes one entry per target keyed by the same UID used in the bake plan, so (unlike the BUILD strategy) no separate merge step is needed.
  • Bumped python-on-whales lower bound to >=0.81.0.

Closes #736, #740
Refs #728, #735

Testing

  • uv run pytest test/ -m "not slow and not image_build" — 2058 passed
  • uv run ruff check / ruff format --check — clean
  • Added test_build_args_metadata_file in test/image/bake/test_bake.py
  • Added TestBuildTargetsBakeStrategy in test/config/test_config.py covering metadata_file forwarding, default None behavior, and metadata being loaded back into targets
  • Added TestStrategyMetadataCompatibility in test/image/test_image_metadata.py (Test: pin the bake/build metadata file contract with real fixtures #740): two real captured metadata fixtures (strategy-bake-metadata.json, strategy-build-metadata.json) plus a parametrized test pinning the contract both strategies must satisfy

python-on-whales 0.81.0 added metadata_file support to
docker.buildx.bake(), matching the existing docker.build() support.
Wire bakery build --metadata-file through the --strategy bake path:

- BakePlan.build() now accepts metadata_file and forwards it to
  `docker buildx bake --metadata-file`.
- BakeryConfig.build_targets()'s BAKE branch passes metadata_file
  through to BakePlan.build() and, on success, loads the resulting
  file back into each target's build_metadata (buildx bake writes one
  entry per target keyed by the same UID used in the bake plan, so no
  merge step is needed, unlike the BUILD strategy).
- Bump python-on-whales lower bound to >=0.81.0.

Refs #728
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

Test Results

2 097 tests  +18   2 097 ✅ +18   8m 9s ⏱️ - 1m 49s
    1 suites ± 0       0 💤 ± 0 
    1 files   ± 0       0 ❌ ± 0 

Results for commit 98572d4. ± Comparison against base commit 5693eac.

♻️ This comment has been updated with latest results.

The `bake` and `build` strategies produce metadata files from entirely
separate code paths -- raw `docker buildx bake --metadata-file` passthrough
vs. `BakeryConfig._merge_sequential_build_metadata_files()` -- yet
`bakery dgoss run --metadata-file` and `bakery ci publish` consume both
through the same loader. Nothing pinned that equivalence, so a divergence
would surface as a broken publish in CI rather than a test failure.

Adds the two real metadata files captured while comparing the strategies
(package-manager 2026.06.0, 6 targets, linux/amd64, --push with a temp
registry) as fixtures, and a parametrized test class asserting the contract
consumers depend on: UID-keyed top level, resolvable `<name>@sha256:...`
image refs, `platform == linux/amd64`, `created_at` resolving from the
descriptor annotation rather than the `datetime.now()` fallback, and
matching UID/tag sets across the two producers.

Also documents the multi-platform degradation: one invocation building
several platforms yields an index descriptor with no platform, so
`platform` is None and dgoss/merge lose per-platform selection.

Closes #740
@bschwedler
bschwedler added this pull request to the merge queue Aug 17, 2026
Merged via the queue into main with commit 976d33f Aug 17, 2026
25 checks passed
@bschwedler
bschwedler deleted the feat/bake-metadata-files branch August 17, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass --metadata-file through to bakery build --strategy bake invocations

2 participants